<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('phone', 20)->default('')->comment('手机号')->unique();
            $table->string('email')->default('')->comment('邮箱');
            $table->string('weixin_openid')->default('')->nullable();
            $table->string('weixin_withdraw_openid')->default('')->nullable();
            $table->string('weixin_withdraw_unionid')->default('')->nullable();
            $table->string('weixin_withdraw_nickname')->default('')->nullable();
            $table->string('weixin_withdraw_avatar')->default('')->nullable();
            $table->string('weixin_unionid')->default('')->nullable();
            $table->string('weixin_nickname')->default('')->nullable();
            $table->string('weixin_avatar')->default('')->nullable();
            $table->string('city')->default('')->nullable();
            $table->string('country')->default('')->nullable();
            $table->string('language')->default('')->nullable();
            $table->string('province')->default('')->nullable();
            $table->string('sex')->default('')->nullable();
            $table->string('password')->nullable()->comment('密码');
            $table->string('security')->default('')->comment('交易密码');
            $table->string('accessToken')->default('')->comment('accessToken');
            $table->string('refreshToken')->default('')->comment('refreshToken');
            $table->dateTime('atExpiredTime')->nullable()->comment('2小时');
            $table->dateTime('rtExpiredTime')->nullable()->comment('7天');
            $table->string('real_name')->default('')->comment('真实姓名');
            $table->string('id_card')->default('')->comment('身份证号');
            $table->string('nickname')->comment('昵称');
            $table->string('avatar')->default('')->comment('用户头像');
            $table->integer('pid')->default(0)->comment("上级id");
            $table->integer('fid')->default(0)->comment("邀请办卡人id");
            $table->tinyInteger('status')->default(1)->comment("状态1正常，2冻结");
            $table->tinyInteger('regType')->comment("0:正常注册1:手机快速登陆注册2：微信快速登陆注册");
            $table->tinyInteger('hasPwd')->default(0)->comment("0:没有1:有");
            $table->tinyInteger('hasPhone')->default(0)->comment("0:没有1:有");
            $table->tinyInteger('hasPayPwd')->default(0)->comment("0:没有1:有");
            $table->string('code')->default(0)->comment("邀请码");
            $table->string('personal_signature')->default('')->comment("用户个性签名");
            $table->tinyInteger('is_member')->default('0')->comment("是否为会员");
            $table->integer('member_start_time')->nullable()->comment("会员开始时间");
            $table->integer('member_end_time')->nullable()->comment("会员结束时间");
            $table->tinyInteger('level')->default('0')->comment("会员等级");
            $table->integer('shop_id')->default('0')->comment("=shops.id");
            $table->integer('robe_num')->default(2)->comment("衣柜数量");
            $table->integer('notification_count')->unsigned()->default(0);
            $table->timestamps();
        });
        DB::statement("ALTER TABLE `users` comment '用户表';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
